{% if settings.GROUPS_ENABLED %}
    {% extends "two_column_body.html" %}
{% else %}
    {% extends "one_column_body.html" %}
{% endif %}
{% import "macros.html" as macros %}
<!-- users.html -->
{% block title %}{% spaceless %}{% trans %}Users{% endtrans %}{% endspaceless %}{% endblock %}
{% block tooltip %}<div class="input-tool-tip">search for people</div>{% endblock %}
{% block forestyle %}
    <link rel="stylesheet" type="text/css" href="{{"/js/wmd/wmd.css"|media}}" />
{% endblock %}
{% block tertiary_header %}{% include "widgets/users_tab_bar.html" %}{% endblock %}
{% block content %}
<div id="content-header">
    <h1 class="section-title" style="margin-bottom: 0.5em; width: 100%;">
    {% if group %}
        {% trans name = group.name|replace('-', ' ')|escape %}Users in group {{name}}{% endtrans %}
    {% else %}
        {% trans %}Users{% endtrans %}
    {% endif %}
    </h1>
</div>
{% if search_query %}
    <p>{% trans search_query=search_query|escape %}users matching query {{search_query}}:{% endtrans %}</p>
{% endif %}
{% if not users.object_list %}
    <p><span>{% trans %}Nothing found.{% endtrans %}</span></p>
{% endif %}
{{ macros.user_list(users.object_list) }}
<div class="pager">
    {{ macros.paginator(paginator_context) }}
</div>              
{% endblock %}
{% block sidebar %}
    {% if group %}
        {# this widget takes variables: group, user_can_join_group, user_is_group_member #}
        {% include "widgets/group_info.html" %}
    {% endif %}
{% endblock %}
{% block endjs %}
    <script type='text/javascript'>
        var Attacklab = Attacklab || {};
        Attacklab.wmd = 1;{# a trick to launch wmd manually #}
        askbot['urls']['upload'] = '{% url upload %}';
        askbot['urls']['load_object_description'] = '{% url load_object_description %}';
        askbot['urls']['save_object_description'] = '{% url save_object_description %}';
        askbot['urls']['save_group_logo_url'] = '{% url save_group_logo_url %}';
        askbot['urls']['delete_group_logo_url'] = '{% url delete_group_logo %}';
        askbot['urls']['join_or_leave_group'] = '{% url join_or_leave_group %}';
    </script>
    <script type='text/javascript' src='{{"/js/editor.js"|media}}'></script>
    {% include "meta/markdown_javascript.html" %}
    <script type='text/javascript' src='{{"/js/jquery.validate.min.js"|media}}'></script>
    <script src='{{"/js/post.js"|media}}' type='text/javascript'></script>
    <script type="text/javascript">
        //todo move javascript out
        {% if settings.ENABLE_MATHJAX or settings.MARKUP_CODE_FRIENDLY %}
            var codeFriendlyMarkdown = true;
        {% else %}
            var codeFriendlyMarkdown = false;
        {% endif %}
        {% if group and request.user.is_authenticated() %}
            $().ready(function(){
                var group_join_btn = new GroupJoinButton();
                group_join_btn.decorate($('.group-join-btn'));
                //setup WMD editor
                if (askbot['data']['userIsAdminOrMod'] === true){
                    //todo: this is kind of Attacklab.init ... should not be here
                    Attacklab.wmd = function(){
                        Attacklab.loadEnv = function(){
                            var mergeEnv = function(env){
                                if(!env){
                                    return;
                                }
                            
                                for(var key in env){
                                    Attacklab.wmd_env[key] = env[key];
                                }
                            };
                            
                            mergeEnv(Attacklab.wmd_defaults);
                            mergeEnv(Attacklab.account_options);
                            mergeEnv(top["wmd_options"]);
                            Attacklab.full = true;
                            
                            var defaultButtons = "bold italic link blockquote code image ol ul heading hr";
                            Attacklab.wmd_env.buttons = Attacklab.wmd_env.buttons || defaultButtons;
                        };
                        Attacklab.loadEnv();
                    };
                    Attacklab.wmd();
                    Attacklab.wmdBase();
                    var group_editor = new UserGroupProfileEditor();
                    group_editor.decorate($('#group-wiki-{{group.id}}'));
                }
                Hilite.exact = false;
                Hilite.elementid = "main-body";
                Hilite.debug_referrer = location.href;
            });
        {% endif %}
    </script>
{% endblock %}
<!-- end users.html -->
